﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RaytracerLib.MathLib;
using TomanuExtensions;
using System.Diagnostics;
using RaytracerLib.Rays;
using RaytracerLib.Lights;

namespace RaytracerLib.ShadowTesters
{
    public abstract class ShadowTester
    {
        protected Scene m_scene;
        protected int m_max_ray_depth;

        protected ShadowTester(Scene a_scene)
        {
            m_scene = a_scene;
            m_max_ray_depth = m_scene.ActiveCamera.Film.MaxRayDepth;
        }

        public static ShadowTester Create(Scene a_scene)
        {
            if (a_scene.RenderOptions.ShadowTestMethod == ShadowTestMethod.Solid)
                return new SolidShadowTester(a_scene);
            else if (a_scene.RenderOptions.ShadowTestMethod == ShadowTestMethod.Attenuation)
                return new AttenuationShadowTester(a_scene);
            else if (a_scene.RenderOptions.ShadowTestMethod == ShadowTestMethod.AttenuationTransmittance)
                return new AttenuationTransmittanceShadowTester(a_scene);
            else if (a_scene.RenderOptions.ShadowTestMethod == ShadowTestMethod.AttenuationTransmittanceAngle)
                return new AttenuationTransmittanceAngleShadowTester(a_scene);
            else if (a_scene.RenderOptions.ShadowTestMethod == ShadowTestMethod.AttenuationTransmittanceAngleFresnell)
                return new AttenuationTransmittanceAngleFresnellShadowTester(a_scene);
            else
                throw new InvalidOperationException();
        }

        public abstract ColorFloat ShadowTest(Intersection a_source_ray_intersection, ShadowRay a_ray, Light a_light);

    }
}
